<template>
  <div id="privilege">  
    <div  style="display:flex;align-items: center;">
          <img class="top_img" src="@/assets/images/a8.png" style="width:35px;height:35px;margin-right:10px;"/>
          <div style="line-height: 40px;font-weight:bold:">特权抢拍区</div>
    </div> 

    <el-form ref="form" :model="form" label-width="70px">  

      <div style="display:flex;align-items: center;">
             
             <div style="width:50px;text-align-last: justify;margin-top:-12px;font-size: 14px;color: #606266;margin-right:10px;">查询项</div>
             

            <el-form-item label="输入编号" >
               <el-input v-model="form.bh" :placeholder="variable_name4 + '编号'" style="width:140px;"></el-input>
            </el-form-item>

             <el-form-item label="选择方式" style="margin-left:10px;">
                <el-select  v-model="form.select_num_mode" placeholder="选择方式"  style="width:140px;">
                    <el-option  v-for="(item,index) in select_data_mode" :key="index" :label="item.name" :value="item.id"></el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="账户查询" style="margin-left:10px;">
               <el-input v-model="form.phone" placeholder="账户查询" style="width:140px;"></el-input>
            </el-form-item>
             
              <div class="buttoon_box">
                <div class="buttoon_box_item"  style="margin-left:10px;background:#FFC600;color:white;" @click="search_but">确 定</div>
                <div class="buttoon_box_item" style="margin-left:10px;border:1px solid #D9D9D9;" @click="refresh_but()">清 空</div>    
            </div>

      </div>

      <div style="display:flex;align-items: center;">
             
             <div style="width:50px;text-align-last: justify;margin-top:-12px;font-size: 14px;color: #606266;margin-right:10px;">筛选项</div>
             
              <el-form-item label="选择日期" >
                 <el-date-picker type="date" :clearable='false' @change="data_change" placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="form.time" style="width:140px;"></el-date-picker>
              </el-form-item>

              <el-form-item label="选择状态" style="margin-left:10px;" >
                <el-select  v-model="form.select_num" placeholder="请选择状态" style="width:140px;">
                    <el-option  v-for="(item,index) in select_data" :key="index" :label="item.name" :value="item.id"></el-option>
                </el-select>
              </el-form-item>
              
              <el-form-item  label="选择蜂巢" style="margin-left:10px;">
                <el-select  v-model="form.select_num_zy" placeholder="请选择蜂巢" style="width:140px;">
                    <el-option  v-for="(item,index) in select_data_zy" :key="index" :label="item.title" :value="item.maid"></el-option>
                </el-select>
            </el-form-item>

             
              <div class="buttoon_box">
                <div class="buttoon_box_item"  style="margin-left:10px;background:#FFC600;color:white;" @click="search_but">确 定</div>
                <div class="buttoon_box_item" style="margin-left:10px;border:1px solid #D9D9D9;" @click="refresh_but()">清 空</div>    
            </div>

      </div>

      <el-row>

        <el-col :span="24" style="text-align: right;">          
           <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="mtk1_but()">
             <img class="custom_color_button1_img" src="@/assets/images/but_bg6.png" />获奖要求
            </el-button> 
           <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="go_participate_but()">
             <img class="custom_color_button1_img" src="@/assets/images/but_bg6.png" />参与人数
            </el-button>     
            <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="mtk2_but()">
             <img class="custom_color_button1_img" src="@/assets/images/but_bg6.png" />时间设置
            </el-button> 
        </el-col>
   
      </el-row>

   
   </el-form>
   <!-- 渲染数据list -->
   <privilege-list :datalist="datalist" @up_list_fun="list_fun"> </privilege-list>

      
   <div style="margin-top:20px;text-align: center;">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="10"  
        layout="prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>

      <!-- 获奖要求 -->
    <el-dialog title="获奖要求" :visible.sync="mtk1"  width="400px">
        <div style="width:100%;"> 

            <el-form ref="form"   label-width="70px" style="width:100%;">     
                <el-form-item label="新人天数">
                    <el-input    v-model="mtk1_form.novice_goods_gobuy_can_days" placeholder="新人天数"></el-input>
                </el-form-item>
                <el-form-item label="抢拍次数">
                    <el-input    v-model="mtk1_form.novice_goods_gobuy_can_number" placeholder="抢拍次数"></el-input>
                </el-form-item>

           </el-form>
            <div style="text-align: center;width:50%;margin:auto;">
                <el-button type="primary" class="custom_color_button" style="width:80%;" @click="mtk1_qr_but()">确认</el-button>
            </div>

        </div> 
    </el-dialog>


      <!-- 修改时间 -->
    <el-dialog title="修改时间" :visible.sync="mtk2"  width="400px">
        <div style="width:100%;"> 

        <el-form ref="form"   label-width="70px" style="width:100%;">
    

              <el-form-item label="开放时间" >
                    <el-time-picker
                          v-model="mtk2_form.begin_time"
                          format="HH:mm" 
                          value-format="HH:mm"
                          placeholder="任意时间点">
                    </el-time-picker>
                </el-form-item>

                <el-form-item label="结束时间" >
                    <el-time-picker
                          v-model="mtk2_form.end_time"
                          format="HH:mm" 
                          value-format="HH:mm"
                          placeholder="任意时间点">
                    </el-time-picker>
                </el-form-item>

                                  
            </el-form>

            <div style="text-align: center;width:50%;margin:auto;">
                <el-button type="primary" class="custom_color_button" style="width:80%;" @click="mtk2_qr_but()">确认</el-button>
            </div>

        </div> 
    </el-dialog>

      
  </div>
</template>

<script>



import PrivilegeList from '@/view/Activitynew/Privilege/PrivilegeList'
export default {
  name: 'privilege',
  data () {
    return {
        datalist:[],
        page:1,
        count:0,
        form:{
          time:'',
          phone:'',
          bh:'',
          select_num:'',
          select_num_zy:'',
          select_num_mode:0
        },
        select_data_zy:[],
        select_data:[{"id":"cancel_no_submit","name":"未上传凭证取消"},{"id":"cancel_no_finished","name":"未完成订单取消"},{"id":"wait_submit","name":"未上传凭证"},
          {"id":"submitted_first","name":"待确认/上传凭证"},{"id":"reject","name":"已驳回"},{"id":"submitted_second","name":"新上传"},{"id":"seller_appeal","name":"出让方申述"},
          {"id":"buyer_appeal","name":"兑换方申述"},{"id":"finish","name":"已完成"},{"id":"overtime","name":"超时自动完成"},{"id":"wait_admin","name":"申述待判定"},
          {"id":"seller_reason","name":"出兑方责任"},{"id":"buyer_reason","name":"兑换方责任"},{"id":"seller_mistake","name":"出让方确认申述"}
          ,{"id":"buyer_mistake","name":"兑换方确认申述"}],
        select_data_mode:[{"id":0,"name":"全部"},{"id":1,"name":"出兑方"},{"id":2,"name":"兑换方"}],
       
        mtk1:false,
        mtk1_form:{
          novice_goods_gobuy_can_days:'',
          novice_goods_gobuy_can_number:'',
        },

        mtk2:false,
        mtk2_form:{
          begin_time:'',
          end_time:'',
        },

    }
  },
 components:{
    PrivilegeList
  },
  created(){
    //  this.form.time = this.getNowDate1()
     this.list_fun()
     this.list_zy()
     this.set_fun()
  },
  mounted (){
    
  },
  methods: {
      list_zy(){
        this.post("/manor/manorOption", {
        }).then(res => { 
            this.select_data_zy = res.result     
            //console.log(this.select_data_zy)                  
        })
      },
      list_time(){
        this.post("/novice_goods/banTime", {
        }).then(res => { 
            this.mtk2_form.begin_time = this.getTime_time(res.result.begin_time)
            this.mtk2_form.end_time = this.getTime_time(res.result.end_time)
            console.log(res,'time')                  
        })
      },
      set_fun(){
        this.post("/novice_goods/limitItem", {
        }).then(res => { 
               this.mtk1_form.novice_goods_gobuy_can_days = res.result.novice_goods_gobuy_can_days
               this.mtk1_form.novice_goods_gobuy_can_number = res.result.novice_goods_gobuy_can_number
            console.log(res,"dddd")                  
        })
      },
      list_fun(){
          this.post("/trade_goods/listOfData", {
              page:this.page,
              pid:this.form.bh,
              onetime:this.form.time,
              telphone:this.form.phone,
              type:this.form.select_num,
              maid:this.form.select_num_zy,
              buyOrSale:this.form.select_num_mode,
              search_all:0, //0 分页 1 全部
              novice:2,
              member_type:1
	        }).then(res => {
            this.count = res.result.count
            this.datalist = res.result.list

              for(let item of this.datalist) {

                 item.voucher_linkList = [this.urlimg + item.voucher_link]  //首次上传凭证图片
                item.again_voucher_linkList = [this.urlimg + item.again_voucher_link]  //重新上传凭证图片
                 item.reason_picturelist =  [this.urlimg + item.reason_picture]  //驳回图片

                item.appeal_picturelist =  [this.urlimg + item.appeal_picture]  //申述图片
              }

            console.log(res)
         })
      },
      mtk1_but(){
         this.mtk1 = true
      },
      mtk1_qr_but(){
         this.post("/novice_goods/setColorItem", {
                    novice_goods_gobuy_can_days:this.mtk1_form.novice_goods_gobuy_can_days,
                    novice_goods_gobuy_can_number:this.mtk1_form.novice_goods_gobuy_can_number,
                }).then(res => {

                    if(res.error_code == 0){
                      this.mtk1 = false
                      this.set_fun()
                     this.open1(res.result,'success')  //提示框
                    }else {
                     this.open1(res.message,'warning')
                }

         })
      },
      mtk2_but(){
        this.list_time()
        this.mtk2 = true
      },
      mtk2_qr_but(){

        this.post("/novice_goods/setBanTime", {
                    begin_time:this.mtk2_form.begin_time,
                    end_time:this.mtk2_form.end_time,
                }).then(res => {

                    if(res.error_code == 0){
                      this.mtk2 = false
                      this.list_time()
                     this.open1(res.result,'success')  //提示框
                    }else {
                     this.open1(res.message,'warning')
                }

         })

      },
      go_participate_but(){
          this.$router.push({
          path: '/index/activitynew/privilege/participate',
          query: {
            
          }
        })
      },
      search_but(){

        this.page = 1
        this.list_fun()
      },

      refresh_but(){
        this.page = 1
        this.form={
          time:'',
          phone:'',
          bh:'',
          select_num:'',
          select_num_mode:0
        }
        this.list_fun()
      },
       data_change(){
        console.log(this.form.time)
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.page = val
        this.list_fun()
        console.log(`当前页: ${val}`);
      }
  }
}
</script>


<style scoped>
.buttoon_box{
  display:flex;margin-bottom:10px;
}
.buttoon_box_item{
  height:40px;line-height:40px;width:60px;font-size:14px;text-align:center;border-radius:5px;
}
.el-input-box>>>input{
  padding: 0px 3px !important;
}
</style>
